package com.anche.cywebnew.Service.systemManager.Impl;

import com.anche.cywebnew.DAO.systemManager.RoleMapper;
import com.anche.cywebnew.DAO.systemManager.RoleResourceMapper;
import com.anche.cywebnew.Pojo.systemManager.RoleResource;
import com.anche.cywebnew.Pojo.systemManager.SysRole;
import com.anche.cywebnew.Service.systemManager.RoleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public Page<SysRole> getRolePager(Integer page, Integer limit) {
        Page<SysRole> page1 = PageHelper.startPage(page, limit);
        roleMapper.getSysRoles();
        return page1;
    }

    @Override
    public void setRoleStatus(String id, String status) {
        SysRole sysRole = new SysRole();
        sysRole.setId(id);
        sysRole.setStatus(status);
        roleMapper.updateRoleById(sysRole);
    }

    @Override
    public void setRole(SysRole sysRole) {
        roleMapper.updateRoleById(sysRole);
    }

    @Override
    public void delRole(String id) {
        roleMapper.deleteRoleById(id);
    }

    @Override
    public void addRole(SysRole sysRole) {
        sysRole.setStatus("1");
        roleMapper.insertSysRole(sysRole);
    }

    @Override
    public List<SysRole> getRoleList() {
        return roleMapper.getSysRoles();
    }
}
